﻿using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace NTmdb.TestProject
{
    /// <summary>
    ///     This is a test class for TmdbCrewMemberTest and is intended
    ///     to contain all TmdbCrewMemberTest Unit Tests
    /// </summary>
    [TestClass]
    public class TmdbCrewMemberTest
    {
        /// <summary>
        ///     A test for TmdbCrewMember Constructor
        /// </summary>
        [TestMethod]
        public void TmdbCrewMemberConstructorTest()
        {
            var target = new TmdbCrewMember();
            Assert.IsNotNull( target );
        }

        /// <summary>
        ///     A test for Department
        /// </summary>
        [TestMethod]
        public void DepartmentTest()
        {
            var target = new TmdbCrewMember();
            string expected = Guid.NewGuid().ToString();
            string actual;
            target.Department = expected;
            actual = target.Department;
            Assert.AreEqual( expected, actual );
        }

        /// <summary>
        ///     A test for Job
        /// </summary>
        [TestMethod]
        public void JobTest()
        {
            var target = new TmdbCrewMember();
            string expected = Guid.NewGuid().ToString();
            string actual;
            target.Job = expected;
            actual = target.Job;
            Assert.AreEqual( expected, actual );
        }

        /// <summary>
        ///     A test for Serialize & Deserialize
        /// </summary>
        [TestMethod]
        [DeploymentItem( @"..\..\TestData\crewMember.json.txt" )]
        public async Task SerializeDeserializeTest()
        {
            var target = new TmdbCrewMember();
            var jsonContent = File.ReadAllText( "crewMember.json.txt" );
            var actual = await target.DeserializeJson<TmdbCrewMember>( jsonContent );

            Assert.AreEqual( "Writing", actual.Department );
            Assert.AreEqual( "Screenplay", actual.Job );
            Assert.AreEqual( 114016, actual.Id );
            Assert.AreEqual( "Travis Beacham", actual.Name );
            Assert.AreEqual( null, actual.ProfilePath );
        }
    }
}